package repository;

        import dbConnect.dbConnecter;
        import java.sql.ResultSet;
        import java.sql.SQLException;
        import java.sql.Statement;
        import java.sql.DriverManager;

public class RegisterRepository {
    public RegisterRepository(){

    }
    public boolean ReleaseUser(String userName,String userAccount,String userPwd,int admin)  throws SQLException {
        dbConnecter Con = new dbConnecter();
        Con.getConnection();
        String sql = "INSERT INTO User_tb(userName,userAccount,userPwd,admin) VALUES ("+dbConnecter.toSql(userName)+","+dbConnecter.toSql(userAccount)+","+dbConnecter.toSql(userPwd)+","+dbConnecter.toSqlint(admin)+")";
        try{
            int res = Con.resultSql(sql);
            if(res>0)
            {
                return true;
            }
            else
            {
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        } finally {
            Con.close();
        }

//        try {
//            int res = Con.resultSql(sql);
//            if ( res> 0) {
//                return true;
//            } else return false;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return false;
//        } finally {
//            Con.close();
//        }
    }
}